package com.xjscrm.server.service.device.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.uzai.mobile.collect.api.dto.MicaTransDto;
import com.uzai.mobile.collect.api.dto.msg.MicaHeartBeatMsg;
import com.uzai.mobile.collect.api.dto.msg.MicaOfflineMsg;
import com.uzai.mobile.collect.api.dto.msg.MicaOnlineMsg;
import com.uzai.trace.TraceGenerate;
import com.xjscrm.common.annotation.MerId;
import com.xjscrm.common.entity.WwCorp;
import com.xjscrm.common.entity.WwDevice;
import com.xjscrm.common.enums.RedisCacheKeyEnum;
import com.xjscrm.common.param.device.WwDeviceMobileCacheDto;
import com.xjscrm.common.utils.DateUtil;
import com.xjscrm.server.common.util.ShortChainUtils;
import com.xjscrm.server.mapper.WwCorpMapper;
import com.xjscrm.server.mapper.WwDeviceMapper;
import com.xjscrm.server.service.common.CorpApplicationService;
import com.xjscrm.server.service.device.WwDeviceInfoService;
import com.xjscrm.server.service.device.WwDeviceService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * 企业微信机器人(WwDevice)表服务实现类
 *
 * @author makejava
 * @since 2024-03-01 17:01:12
 */
@Service
@Slf4j
public class WwDeviceInfoServiceImpl implements WwDeviceInfoService {
    @Autowired
    private WwDeviceMapper wwDeviceMapper;

    /**
     * 机器人下线
     *
     * @param merId
     * @return 实例对象
     */
    public WwDevice selectById(@MerId Long merId, Long deviceUniqueId){
        //判断是否存在该企业微信
        return wwDeviceMapper.queryById(deviceUniqueId);
    }

    /**
     * 通过企业corpId查询数据列表
     *
     * @param merId 主键
     * @return 实例对象
     */
    public List<WwDevice> queryByCorpId(@MerId Long merId, String corpId){
        return wwDeviceMapper.queryByCorpId(corpId, merId);
    }

}
